home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group95b.txt / 000032_icon-group-sender _Wed May 31 13:53:35 1995.msg < prev    next >
Internet Message Format  |  1995-09-18  |  1KB

  1. Received: by cheltenham.cs.arizona.edu; Thu, 1 Jun 1995 10:38:30 MST
  2. To: icon-group-l@cs.arizona.edu
  3. Date: 31 May 1995 13:53:35 -0700
  4. From: dave@cs.arizona.edu (Dave Schaumann)
  5. Message-Id: <3qil0f$dnd@lectura.CS.Arizona.EDU>
  6. Organization: University of Arizona CS Department, Tucson AZ
  7. Sender: icon-group-request@cs.arizona.edu
  8. References: <KRINKE.95May30183109@infbspsk.cs.tu-bs.de>
  9. Subject: Re: problem with 'key'
  10. Errors-To: icon-group-errors@cs.arizona.edu
  11.  
  12. In article <KRINKE.95May30183109@infbspsk.cs.tu-bs.de>,
  13. Jens Krinke <krinke@ips.cs.tu-bs.de> wrote:
  14. >Hi, 
  15. >
  16. >i have a problem with 'key':  example:
  17. >
  18. >record test(foo, bar)
  19. >
  20. >procedure main()
  21. >    a := table()
  22. >    a[test(3,4)] := "a(3,4)"
  23. >    a[test(1,2)] := "a(1,2)"
  24. >    every write("entry: ", image(!a))
  25. >    every write("key: ", image(!key(a)))
  26.                                 ^
  27. >    every k := !key(a) do
  28.                 ^
  29. >    write("check: ", image(a[k]))
  30.  
  31. "key" is already a generator -- there's no need to use the '!' operator
  32. with it.  The reason you are getting the results you are is that key()
  33. returns first the record "a(1,2)".  Then '!' causes iteration over the
  34. fields of that record, giving the result you see in the first loop.
  35. Similarly in the second loop, 'k' goes over the values 1, 2, 3, and 4.
  36. None of these are keys in your table, and so all references have the
  37. default (&null) value.
  38.  
  39. -Dave
  40.